package com.workflow.server.utils;

import com.workflow.server.enums.ReturnCode;
import lombok.Data;

import java.util.List;

/**
 * @author : ForeverKobe
 */
@Data
public class MultiResponse<T> {
    private int status;
    private String message;
    private List<T> data;
    private long timestamp;

    public MultiResponse() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> MultiResponse<T> success(List<T> data) {
        MultiResponse<T> resultData = new MultiResponse<>();
        resultData.setStatus(ReturnCode.RC100.getCode());
        resultData.setMessage(ReturnCode.RC100.getMessage());
        resultData.setData(data);
        return resultData;
    }

    public static <T> MultiResponse<T> fail(int code, String message) {
        MultiResponse<T> resultData = new MultiResponse<>();
        resultData.setStatus(code);
        resultData.setMessage(message);
        return resultData;
    }
}

